Repository navigation
Keep a grammar applied inside a thinking-budget block on request - #213
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bridge half of leehack/llamadart#1954.
Problem
grammar_is_active()pauses every grammar while the thinking budget is inside a reasoning block. A grammar that takes the block itself (rootthink-body "</think>" ..., written for a prompt that ends inside the block) never sees the forced</think>, resumes at its start and takes the reply as reasoning.Change (additive; default behaviour and wire payloads unchanged)
CompletionOptions.thinkingBudget.pauseGrammar?: boolean | null; omitted,nullortruepauses as before. Boolean-validated (TypeError: CompletionOptions.thinkingBudget.pauseGrammar must be a boolean; got X.).thinkingBudgetPauseGrammar;pauseGrammar: falseis rejected without it.llamadart_webgpu_set_next_grammar_reasoning_pause(int32_t), called byruntime.tsafter_setNextGrammarand before begin, only whenpauseGrammar === false; inEXPORTED_FUNCTIONS.grammar_is_active()returns true when the budget is null or the flag is false; the flag is reset inend_generation_state.js/outputs regenerated bynpm run check:js;docs/api.mdandCHANGELOG.md(Unreleased) updated.Validation
npm run check:js(603 tests)node scripts/ci/verify_ci_reliability.mjstests/bridge/thinking_budget_grammar_native_test.mjsoncb6383fsourcesscripts/smoke/grammar.mjsopen-budget-taking-grammar(pauseGrammar: false, expects</think>yes|no)Local emcc is 6.0.13 (pin 6.0.8), so the wasm build and grammar smoke rely on this PR's CI.
No candidate, qualification or publish workflow is dispatched; publishing assets needs maintainer approval.